# -*- coding:utf-8 -*-
from rest_framework import serializers
from rest_framework.serializers import ModelSerializer
from ..models.interface import Interface


class InterfaceSer(ModelSerializer):
    class Meta:
        model = Interface
        fields = '__all__'


# 查询分类接口时，调用接口序列化查询接口名
class CatInterfaceSer(ModelSerializer):
    label = serializers.CharField(source="interface_name")
    index = serializers.CharField(source="index_num")
    # 自定义的type，用来标记是接口
    type = serializers.CharField(default="interface")

    class Meta:
        model = Interface
        fields = ["id", "label", "interface_method", "index", "type"]
